﻿@model smp.ButterflyCakes.Models.FormModels.Order.OrderSummaryModel
<div class="container">
    <div class="container-fluid">
        @if(ViewBag.Error != null)
        {
            <div class="alert alert-block alert-error">
                <p>@ViewBag.Error</p>
            </div>
        }
        @Html.ValidationSummary(true)
    </div>
    <form class="form-horizontal" id="editform" url="/order/saveordersummary">
        @Html.HiddenFor(x => x.ComponentId)
        @Html.HiddenFor(x => x.OrderId)
        <div class="control-group">
            <label class="control-label" for="Name">
                Title</label>
            <div class="controls">
                <input class="input-xxlarge" type="text" id="Title" name="Title" placeholder="Enter a name" value="@Model.Title"/>
                @Html.ValidationMessageFor(x => x.Title)
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Due">
                Due Date</label>
            <div class="controls">
                <input class="datecontrol input-medium" id="Due" name="Due" placeholder="Due date" value="@Model.DueDisplay"/>
                @Html.ValidationMessageFor(x => x.Due)
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="Summary">
                Summary</label>
            <div class="controls">
                <textarea class="input-xxlarge" rows="10" cols="20" id="Summary" name="Summary" placeholder="Summary Text">@Model.Summary</textarea>
            </div>
        </div>
    </form>
    <div class="form-actions">
        <button id="save" type="submit" class="btn btn-success">
            Next
        </button>
        <button id="cancel" type="submit" class="btn btn-danger hide">
            Cancel
        </button>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {

        $('#editform').validate(
            {
                rules: {
                    Title: {
                        required: true,
                        minlength: 4
                    },
                    Due: {
                        required: true
                    }
                },
                highlight: function (element) {
                    $(element).closest('.control-group').removeClass('success').addClass('error');
                },
                success: function (element) {
                    element
                        .text('OK!').addClass('valid')
                        .closest('.control-group').removeClass('error').addClass('success');
                }
            });
    });
</script>
